package com.jindianjichi.subject.domain.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池的config管理
 */
@Configuration
public class ThreadPoolConfig {
    @Bean(name = "labelThreadPool")
    public ThreadPoolExecutor getThreadPoolExecutor() {
        return new ThreadPoolExecutor
                (10,
                        20, 5, TimeUnit.SECONDS,
                        new LinkedBlockingQueue<>(40),
                        new CustomNameThreadFactory("label"),new ThreadPoolExecutor.CallerRunsPolicy());
    }
}
